<?php
namespace app\index\controller;

use think\Controller;
use app\index\model\Account as AccountModel;
use app\index\model\User as UserModel;
use app\index\model\Usertree as UTModel;
use app\index\model\Deallist as DLModel;
use app\index\model\Businesscenter as BCModel;
use app\index\model\Setting as STModel;
use think\Session;
use Core;





class Come extends  Base{

    //用户登录展示页面
    public function index(){



        $UserName = Session::get('username');
        $UserID = Session::get('userid');

        $this->assign('username',$UserName);
        $this->assign('userid',$UserID);




        //初始化User模型
        $User = new UserModel();

       $data = $User->where('import_man_id',$UserID)->select();


       //检测账户，推荐人总付款达到总积分的30倍，就改变账户状态
        $UserAcoount = new AccountModel();
        $UserData = $UserAcoount->where('user_id',$UserID)->find();

         if($UserData['allscore'] > ($UserData['allpay'] * 30)){
             $UserAcoount->save([
                 'status' => '10'
             ],['user_id' => $UserID]
             );

             $this->success('已达利润上限，帐号被锁定！！！不再获得利润！！！如有疑问请联系客服');
         }


        // dump($data);die;
//       foreach ($data as $value){
//       	echo $value['id'];
//       }


        




        //初始化模型

        $accountModel = new AccountModel();

        $data = $accountModel->where('user_id', $UserID)->find();

        $this->assign('data',$data);

        return $this->fetch();
    }

}
